package com.artPreter.controller;



import com.baomidou.mybatisplus.core.metadata.IPage;
import com.artPreter.pojo.PlateType;
import com.artPreter.pojo.Result;
import com.artPreter.pojo.TemplateDetail;
import com.artPreter.service.ITemplateDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 模板详情表 前端控制器
 * </p>
 *
 * @author jarvis
 * @since 2024-11-18
 */
@RestController
@RequestMapping("/templateDetail")
public class TemplateDetailController {

    @Autowired
    private ITemplateDetailService templateDetailService;

    /**
     * 添加模板
     * @param
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody TemplateDetail templateDetail) {
        templateDetailService.add(templateDetail);
        return Result.success();
    }

    /**
     * 修改模板
     * @param
     * @return
     */
    @PostMapping("/edit")
    public Result edit(@RequestBody TemplateDetail templateDetail) {
        templateDetailService.edit(templateDetail);
        return Result.success();
    }

    /**
     * 删除模板
     * @param
     * @return
     */
    @PostMapping("/delete")
    public Result delete(@RequestBody TemplateDetail templateDetail) {
        templateDetailService.delete(templateDetail);
        return Result.success();
    }

    /**
     * 模板分页分页
     * @param currentPage
     * @param size
     * @param
     * @return
     */
    @PostMapping("/getPage")
    public Result getPage(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody TemplateDetail templateDetail) {
        IPage<TemplateDetail> templateDetailIPage = templateDetailService.getPage(currentPage, size, templateDetail);
        return Result.success(templateDetailIPage);
    }

    /**
     * 模板列表
     * @param templateDetail
     * @return
     */
    @PostMapping("/getList")
    public Result getPage(@RequestBody TemplateDetail templateDetail) {
        List<TemplateDetail> templateDetailList = templateDetailService.getList(templateDetail);
        return Result.success(templateDetailList);
    }





}
